<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			span{
				
				color: red;
			}
		</style>
	</head>
	<body>
		<input type="text" name="" id="username" value="" />
		<input type="password" name="" id="password" value="" />
		<span id="spn">
		</span>
		<input type="button" name="" id="btn" value="登录" />
		<ul class="list">
			<!--<li>
				<h2></h2>
				<img src="" />
				<p></p>
			</li>-->
		</ul>
		<script src="cookie.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var btn  = document.getElementById('btn');
			var txt1 = document.getElementById('username');
			var txt2 = document.getElementById('password');
			var spn = document.getElementById('spn');
			btn.onclick = function(){
			setcookies('username',txt1.value,70);
	        setcookies('password',txt2.value,70);
			var username = txt1.value;
			var password = txt2.value;
			var xkl1 = new XMLHttpRequest();
			var url ='http://jx.xuzhixiang.top/ap/api/login.php?username=11&password=1212'
			xkl1.open('get',url);
			xkl1.send(null);
				xkl1.onload = function(){
				if(xkl1.status == 200){
					console.log(xkl1.responseText);
					var obj = JSON.parse(xkl1.responseText);
					console.log(obj.msg);
					spn.innerHTML = obj.msg;
				   if(spn.innerHTML == "登录成功")
				    {
				       location.href='details.html';
				   }else{
					spn.style.display = 'inline-block';
					spn.innerHTML = '请核对登录信息';
				   }
					
				   
				   }
				 }		    
			   }
		
	  


			
</script>
	</body>
</html>

